<template>
  <div>
    <!-- 基本的结构布局 -->
    <el-container>
      <el-header
        >大型后台管理项目！！！
        <div>{{ getUserInfo.username }}</div>
        <el-button @click="logout" type="danger" size="mini">退出</el-button>
      </el-header>
      <el-container>
        <el-aside>
          <v-nav></v-nav>
        </el-aside>
        <el-main>
          <!-- 二级路由出口 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import vNav from "../components/vNav";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters(["getUserInfo"]),
  },
  mounted() {
    console.log(this.getUserInfo, "存储的state值");
  },
  components: {
    vNav,
  },
  methods: {
    ...mapActions(["changeUserInfoAction"]),
    //封装一个退出登录事件
    logout() {
      //触发修改userInfo的vuex 强制跳转到登录页
      this.changeUserInfoAction(false);
      this.$router.replace("/login");
    },
  },
};
</script>

<style lang="stylus" scoped>
@import '../stylus/index.styl';

.el-header {
  background: $firstBgColor;
  height: 80px !important;
}

.el-aside {
  width: 220px !important;
}
</style>
